package com.demo.juc.state;


/**
 * 线程在Warting上等待:
 * 获取当前类Class对象的synchronized锁，也就是说，这个类无论创建
 * 多少个实例，synchronized锁都是同一个，并且线程会处于等待状态。
 *
 * "WaitingThread" #14 prio=5 os_prio=0 tid=0x000000001fa4e000 nid=0x3d14 in Object.wait() [0x000000002094f000]
 *    java.lang.Thread.State: WAITING (on object monitor)
 */
public class WaitingThread implements Runnable {
    @Override
    public void run() {
        while (true) {
            synchronized (WaitingThread.class) {
                try {
                    WaitingThread.class.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
